const express = require('express')
const router = express.Router();
const axios = require('../../axios.js')
const { bookingOrdersUrlMap } = require('../../api.js')

router.post('/checkUser', async (req, res) => {
    const data = await axios.post(bookingOrdersUrlMap.checkUser, {
        _json_att: '',
    }, {
        headers: {
            // 请求查询接口成功关键语句
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Cookie': 'JSESSIONID=538613642E484D52680E0222EBC64DF8; route=495c805987d0f5c8c84b14f60212447d; BIGipServerotn=1876492554.24610.0000;'

        }
    })
    console.warn('oooo', data)
    res.json(data)
})

// 有点问题 globalRepeatSubmitToken数据一直为null TODO
router.post('/initDc', async (req, res) => {
    const data = await axios.post(bookingOrdersUrlMap.initDc, req.body)
    res.setHeader('Content-Type', 'text/html;charset=utf-8');
    res.setHeader('Cache-Control', 'no-cache,no-store');
    res.setHeader('Cache-Control', 'no-cache,no-store');
    res.setHeader('Pragma', 'no-cache');
    res.send(data);
})

router.post('/checkOrderInfo', async (req, res) => {
    const data = await axios.post(bookingOrdersUrlMap.checkOrderInfo, req.body)
    res.setHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    res.setHeader('Cookie', req.headers.cookie);
    console.warn('data', data)
    res.send(data);
})

module.exports = router

